<template>
	<view class="p20 h-max">
		<view class=" bg-fff pt20 h-max radius20 pr">
			<view v-for="(item,index) in list" :key="index" class="bg-f8f m20 radius20 relative pr"
				@click="current = index">
				<image :src="item.img" class="h200 " mode=""></image>
				<view class="absolute top0 h200 pt50 w-max" style="padding-left: 348rpx;"
					:class="current == index?'bg-zs-007':''">
					<view class="fs32 fw-600" :class="current == index?'color-zs':''">
						{{item.name}}
					</view>
					<view class="fs28 color-999 mt26" :class="current == index?'color-zs':''">
						{{item.desc}}
					</view>
				</view>
				<view class="absolute top0 right0" v-if="auth.identity==item.identity">
					<view class="fs22 p8 bg-zs color-fff" style="border-bottom-left-radius: 10rpx;">当前身份</view>
				</view>
			</view>
			<view class="h120"></view>
			<view class="pa bottom0 w-max flex">
				<view class="flex1 p20" v-if="auth.identity">
					<u-button type="warning" plain ripple @click="$navBack()">返回</u-button>
				</view>
				<view class="flex2 p20" v-if="data.is_auth==0">
					<u-button type="warning" ripple @click="data.nav?$u.route(data.nav):$msg('暂未开放')">立即认证</u-button>
				</view>
				<view class="flex2 p20" v-else-if="data.is_auth==1&&data.status==0">
					<u-button type="warning" ripple plain @click="changeIdentity">认证审核中</u-button>
				</view>
				<view class="flex2 p20" v-else-if="data.is_auth==1&&data.status==1">
					<u-button type="warning" ripple @click="changeIdentity">切换身份</u-button>
				</view>
				<view class="flex2 p20" v-else-if="data.is_auth==1&&data.status==2">
					<u-button type="warning" ripple @click="$u.route(data.nav)">认证失败,重新认证</u-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: this.$list('identityList'),
				current: 0,
				auth: ''
			};
		},
		computed: {
			data() {
				let aa = ''
				aa = this.list[this.current] || ''
				let item = this.auth[aa.identity] || {}
				aa = {
					...aa,
					...item,
				}
				return aa
			}
		},
		onLoad() {
		},
		onShow() {
			this.getAuth()
		},
		methods: {
			getAuth(e) {
				this.$request('/master/my/getAuth').then(res => {
					this.auth = res.data
				})
			},
			changeIdentity(e) {
				this.$request('/master/my/changeIdentity', {
					identity: this.data.identity
				}).then(res => {
					this.$msg(res.msg)
					this.getAuth()
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;
	}
</style>
